package com.idemon.ds.util;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.apache.log4j.Logger;

public class OnlineListener implements HttpSessionListener {

	private Logger log = Logger.getLogger(getClass());

	private static List<String> onlines = new ArrayList<String>(0);

	@Override
	public void sessionCreated(HttpSessionEvent arg0) {
		onlines.add(arg0.getSession().getId());
		log.info("当前在线人数：" + onlines.size());
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent arg0) {
		onlines.remove(arg0.getSession().getId());
		log.info("当前在线人数：" + onlines.size());
	}

}
